<!-- include tpl=head menutitle=$page_rs.title js="js/jquery.zoombie.js" -->
<!-- if $cate_rs.banner || $page_rs.banner -->
<div class="banner" style="background-image:url('{$cate_rs.banner ? $cate_rs.banner.filename : $page_rs.banner.filename}');"><img src="{#images#}/blank.gif" alt="{$cate_rs.title}" /></div>
<!-- /if -->
<script type="text/javascript">
var price_base = '{$rs.price}';
function attr_select(id,aid)
{
	$("#attr_"+aid).val(id);
	$("div[name=attr"+aid+"]").each(function(i){
		var tid = $(this).attr('data');
		if(tid == id){
			$(this).addClass("selected");
			//判断价格
			var new_price = $(this).attr("price");
			if(new_price && parseFloat(new_price)>0){
				price = parseFloat(price) + parseFloat(new_price);
				$("#showprice").html(price);
			}
		}else{
			$(this).removeClass('selected');
		}
	});
	var price = price_base;
	$("input[name=attr]").each(function(i){
		var val = $(this).val();
		if(val){
			var newprice = $("div[data="+val+"]").attr("price");
			if(newprice && parseFloat(newprice)>0){
				price = parseFloat(price) + parseFloat(newprice);
			}
		}
	});
	var url = api_url('cart','price_format','price='+$.str.encode(price));
	$.phpok.json(url,function(rs){
		if(rs.status){
			$("#showprice").html(rs.info);
		}
	});
}
function update_apps(name)
{
	var price = $("#"+name+"_id").find("option:selected").attr("data-price");
	price_base = price;
	var url = api_url('cart','price_format','price='+$.str.encode(price));
	$.phpok.json(url,function(rs){
		if(rs.status){
			$("#showprice").html(rs.info);
		}
	});
}
$(document).ready(function(){
	//按住鼠标可以查看大图
	$('#product_img .big li').zoombie({on:'grab'});
	$("#product_img").slide({
		'titCell':'.hd li',
		'mainCell':'.big',
		'effect':"fold",
		'autoPlay':true
	});
	$("#minus").click(function(){
		var o = $("#buycount").val();
		if(o<2){
			$.dialog.alert('要购买的数量不能少于1');
			return false;
		}
		o = parseInt(o) - 1;
		$("#buycount").val(o);
	});
	$("#plus").click(function(){
		var o = $("#buycount").val();
		o = parseInt(o) + 1;
		$("#buycount").val(o);
	});
});
</script>
<div class="main product">
	<!-- include tpl=block/breadcrumb -->
	<div class="left am-panel-group">
		<!-- include tpl=block/catelist pid=$page_rs.id cid=$cate_rs.id title=$page_rs.title -->
		<!-- include tpl=block/contact -->
		<!-- include tpl=block/hot_article -->
	</div>
	<div class="right">
		<div class="am-g">
			<div class="am-u-sm-5">
				<div class="proimg">
					<div class="product_img" id="product_img">
						<ul class="big">
							<!-- if !$rs.pictures && $rs.thumb -->
							<li><img src="{$rs.thumb.gd.thumb}" _src="{$rs.thumb.gd.auto}" border="0" alt="{$value.title}" /></li>
							<!-- /if -->
							<!-- loop from=$rs.pictures key=$key value=$value -->
							<li><img src="{$value.gd.thumb}" _src="{$value.gd.auto}" border="0" alt="{$value.title}" /></li>
							<!-- /loop -->
						</ul>
						<ul class="hd">
							<!-- if !$rs.pictures && $rs.thumb -->
							<li href="{$rs.thumb.gd.auto}" thumb="{$rs.thumb.gd.thumb}"></li>
							<!-- /if -->
							<!-- loop from=$rs.pictures key=$key value=$value -->
							<li href="{$value.gd.auto}" thumb="{$value.gd.thumb}"></li>
							<!-- /loop -->
						</ul>
					</div>
				</div>
				<div style="text-align:center;line-height:170%;"><img src="images/zoom.png" /> 鼠标按住图片可看放大效果</div>
				<!-- if $config.code.share -->
				<div style="margin-top:5px;">{$config.code.share}</div>
				<!-- /if -->
			</div>
			<div class="am-u-sm-7">
				<h1>{$rs.title}</h1>
				<ul class="am-list am-list-static">
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>查看次数</b></div>
							<div class="am-u-sm-8">{$rs.hits}</div>
						</div>
					</li>
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>添加时间</b></div>
							<div class="am-u-sm-8">{func time_format $rs.dateline}</div>
						</div>
					</li>
					<!-- if $rs.tag -->
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>标签</b></div>
							<div class="am-u-sm-8">
								<!-- loop from=$rs.tag key=$key value=$value id=$tmpid -->
								<!-- if $value.index -->，<!-- /if --><a href="{$value.url}">{$value.title}</a>
								<!-- /loop -->
							</div>
						</div>						
					</li>
					<!-- /if -->
					<!-- loop from=$rs.apps key=$key value=$value id=$tmpid -->
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>{$value.me.title}</b></div>
							<div class="am-u-sm-8">
								<select name="{$key}_id" id="{$key}_id" data-name="apps" data-id="{$key}" onchange="update_apps('{$key}')">
									<!-- loop from=$value.list key=$k value=$v id=$idxx -->
									<option value="{$value.id}" data-price="{$v.price}"{if $value.rs.id == $v.id} selected{/if}>{$v.title}</option>
									<!-- /loop -->
								</select>
							</div>
						</div>
					</li>
					<!-- if $value.rs -->
					<script type="text/javascript">
					$(document).ready(function(){
						update_apps('{$key}');
					});
					</script>
					<!-- /if -->
					<!-- /loop -->
					<!-- loop from=$rs.attrlist key=$key value=$value -->
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>{$value.title}</b></div>
							<div class="am-u-sm-8">
								<input type="hidden" name="attr" id="attr_{$value.id}" value="" />
								<!-- loop from=$value.rslist key=$k value=$v id=$tmpid -->
								<div class="attr" name="attr{$value.id}" data="{$v.id}" price="{$v.price}" weight="{$v.weight}" volume="{$v.volume}" onclick="attr_select('{$v.id}','{$value.id}')">{$v.title}</div>
								<!-- /loop -->
							</div>
						</div>
					</li>
					<!-- /loop -->
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>购买数量：</b></div>
							<div class="am-u-sm-8 am-form">
								<input name="buycount" id="buycount" value="1" type="number" min="1" />
							</div>
						</div>
					</li>
					<li>
						<div class="am-g">
							<div class="am-u-sm-4"><b>价格</b></div>
							<div class="am-u-sm-8"><span class="price" style="color:red;font-size:16px;" id="showprice">{func price_format $rs.price $rs.currency_id}</span></div>
						</div>
					</li>
				</ul>
				<div>
					<button type="button" class="am-btn am-btn-primary" onclick="$.cart.add('{$rs.id}',$('#buycount').val())"><i class="am-icon-shopping-cart"></i> 加入购物车</button>
					<button type="button" class="am-btn am-btn-warning am-fr" onclick="$.cart.onebuy('{$rs.id}',$('#buycount').val())"><i class="am-icon-check"></i> 立即购买</button>
				</div>
			</div>
		</div>
		<div class="clear"></div>
		<div class="am-tabs"  data-am-tabs="{noSwipe: 1}">
			<ul class="am-tabs-nav am-nav am-nav-tabs">
				<li class="am-active"><a href="#content-intro">商品介绍</a></li>
				<!-- if $rs.pictures --><li><a href="#content-pictures">商品图集</a></li><!-- /if -->
				<!-- if $rs.package --><li><a href="#content-package">包装清单</a></li><!-- /if -->
				<li><a href="#content-protection">售后保障</a></li>
				<!-- if $page_rs.comment_status --><li><a href="#content-comment">商品评价</a></li><!-- /if -->
			</ul>
			<div class="am-tabs-bd">
				<div class="am-tab-panel am-fade am-in am-active" id="content-intro">{$rs.content}</div>
				<!-- if $rs.pictures -->
				<div class="am-tab-panel am-fade" id="content-pictures">
					<!-- loop from=$rs.pictures key=$key value=$value id=$tmpid -->
					<p align="center"><img src="{$value.gd.auto}" border="0" /></p>
					<!-- /loop -->
				</div>
				<!-- /if -->
				<!-- if $rs.package -->
				<div class="am-tab-panel am-fade" id="content-package">{func nl2br $rs.package}</div>
				<!-- /if -->
				<div class="am-tab-panel am-fade" id="content-protection"><!-- php:$t = phpok('after-sale-protection') -->{$t.content}</div>
				<!-- if $page_rs.comment_status -->
				<div class="am-tab-panel am-fade" id="content-comment"><!-- include tpl=block/comment tid=$rs.id --></div>
				<!-- /if -->
			</div>
		</div>
	</div>
</div>

<!-- include tpl=foot -->
